//JavaScript Framework 2.0 Code
try{
Type.registerNamespace('com.yonyou.ncmm_pac_pda.ReturnOutQueryController');
com.yonyou.ncmm_pac_pda.ReturnOutQueryController = function() {
    com.yonyou.ncmm_pac_pda.ReturnOutQueryController.initializeBase(this);
    this.initialize();
}
function com$yonyou$ncmm_pac_pda$ReturnOutQueryController$initialize(){
    //you can programing by $ctx API
    //get the context data through $ctx.get()
    //set the context data through $ctx.push(json)
    //set the field of the context through $ctx.put(fieldName, fieldValue)
    //get the parameter of the context through $ctx.param(parameterName)
    //Demo Code:
    //    var str = $ctx.getString();      //获取当前Context对应的字符串
    //    alert($ctx.getString())          //alert当前Context对应的字符串
    //    var json = $ctx.getJSONObject(); //获取当前Context，返回值为json
    //    json["x"] = "a";        //为当前json增加字段
    //    json["y"] = [];           //为当前json增加数组
    //    $ctx.push(json);            //设置context，并自动调用数据绑定
    //    
    //    put方法需手动调用databind()
    //    var x = $ctx.get("x");    //获取x字段值
    //    $ctx.put("x", "b");     //设置x字段值
    //    $ctx.put("x", "b");     //设置x字段值
    //    $ctx.databind();            //调用数据绑定才能将修改的字段绑定到控件上
    //    var p1 = $param.getString("p1");   //获取参数p2的值，返回一个字符串
    //    var p2 = $param.getJSONObject("p2");   //获取参数p3的值，返回一个JSON对象
    //    var p3 = $param.getJSONArray("p3");   //获取参数p1的值，返回一个数组
    
    //your initialize code below...
    
}
    
function com$yonyou$ncmm_pac_pda$ReturnOutQueryController$evaljs(js){
    eval(js)
}

//清除值
function com$yonyou$ncmm_pac_pda$ReturnOutQueryController$doClear(sender, args){
var json={};
$ctx.push(json);
}
//物料参照
function com$yonyou$ncmm_pac_pda$ReturnOutQueryController$materialRef(sender, args){
     NCMMPubUtil.openRefPage("PDAMATERIAL", "qmaterial","cmaterialvid","pk_material",null);
}
//部门参照
function com$yonyou$ncmm_pac_pda$ReturnOutQueryController$deptRef(sender, args){
     NCMMPubUtil.openRefPage("PDADEPT", "qdept","cdeptid","pk_dept","");
}
//后退
function com$yonyou$ncmm_pac_pda$ReturnOutQueryController$cancle(sender, args){
$view.close();
}
//查询
function com$yonyou$ncmm_pac_pda$ReturnOutQueryController$doQuery(sender, args){
        var condition = {};
		$ctx.dataCollect();
		//物料 
		if($id("qmaterial").get("value") != "") {
			condition["cmaterialvid"] = " = '" + $ctx.getString("cmaterialvid") + "'";
		}
		//单据号
		if($id("qbillcode").get("value") != "") {
			condition["vbillcode"] = " = '" + $id("qbillcode").get("value").toString() + "'";
		}
		//部门
		if($id("qdept").get("value") != "") {
			condition["cdptid"] = " = '" + $ctx.getString("cdeptid") + "'";
		}		
		//批次号
		if($id("qbatchcode").get("value") != "") {
			condition["vbatchcode"] = " = '" + $id("qbatchcode").get("value").toString() + "'";
		}
		if($id("qbilldatestar").get("value") != "" && $id("qbilldateend").get("value") != "") {
			condition["dbilldate"] = "between '" + $id("qbilldatestar").get("value").toString() + " 00:00:00" + "' and '" + $id("qbilldateend").get("value").toString() + " 23:59:59" + "'";
		} else {
			//单据日期从		
			if($id("qbilldatestar").get("value") != "") {
				condition["dbilldate"] = " >= '" + $id("qbilldatestar").get("value").toString() + " 00:00:00'";
			}
			//单据日期到
			if($id("qbilldateend").get("value") != "") {
				condition["dbilldate"] = " <= '" + $id("qbilldateend").get("value").toString() + " 23:59:59'";
			}
		}
		$view.closeWithCallBack({
			"qcondition": condition
		});
}
//加载页面
function com$yonyou$ncmm_pac_pda$ReturnOutQueryController$onload(sender, args){
 var json = {};
		var nowdate = NCMMPubUtil.getNowDate();
		json["qbilldatestar"] = nowdate;
		json["qbilldateend"] = nowdate;
		//	$alert("json="+$jsonToString(json));
		$ctx.push(json);
}
//申请类型参照
function transTypeRef(sender, args){
   var sql =" where parentbilltype='4455'";
   NCMMPubUtil.openRefPage("PDABILLTYPE", "qtranstype","cbilltypeid", "pk_billtypeid",sql);
}
com.yonyou.ncmm_pac_pda.ReturnOutQueryController.prototype = {
    onload : com$yonyou$ncmm_pac_pda$ReturnOutQueryController$onload,
    doQuery : com$yonyou$ncmm_pac_pda$ReturnOutQueryController$doQuery,
    cancle : com$yonyou$ncmm_pac_pda$ReturnOutQueryController$cancle,
    deptRef : com$yonyou$ncmm_pac_pda$ReturnOutQueryController$deptRef,
    materialRef : com$yonyou$ncmm_pac_pda$ReturnOutQueryController$materialRef,
    doClear : com$yonyou$ncmm_pac_pda$ReturnOutQueryController$doClear,
     initialize : com$yonyou$ncmm_pac_pda$ReturnOutQueryController$initialize,
    evaljs : com$yonyou$ncmm_pac_pda$ReturnOutQueryController$evaljs
};
com.yonyou.ncmm_pac_pda.ReturnOutQueryController.registerClass('com.yonyou.ncmm_pac_pda.ReturnOutQueryController',UMP.UI.Mvc.Controller);
}catch(e){$e(e);}
